package com.rykj.base.refreshview.data;

/**
 * Description: author: zhangsan on 2017/8/11 下午2:38.
 */

public interface IDataSource<Data> {

    int REFRESH = 111;
    int LOADMORE = 112;

    /**
     * @param loadAction
     *         :REFRESH  LOADMORE
     */
    void requestData(int loadAction, IDataSourceResultHandler<Data> handler);

    void cancel();

    boolean hasMore();

    void setTotalPage(int totalPage);

    int getCurrentPage();

    void setCurrentPage(int page);


    //   IDataSourceResultHandler<Data> getResultHandler();

    /**
     * Description: author: zhangsan on 2017/8/12 上午10:28.
     */

    interface IDataSourceResultHandler<Data> {

        void handleResult(int loadAction, Data data);

        void handleError(Throwable throwable);

        void handleErrorMsg(int code ,String msg);

    }
}
